package com.ikas.ai.server.module.appraise.controller;

import com.ikas.ai.handle.JsonResult;
import com.ikas.ai.server.aop.Pageable;
import com.ikas.ai.server.module.AbstractBean;
import com.ikas.ai.server.module.appraise.dto.req.ResultPageReqDTO;
import com.ikas.ai.server.module.appraise.model.AppraiseResult;
import com.ikas.ai.server.module.appraise.service.AppraiseResultService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 评价综合结果
 *
 * @author hubowei
 * @email hu.bowei@ikasinfo.com
 * @date 2023-01-30 15:01:30
 */
@RestController
@RequestMapping("/appraise/result")
public class AppraiseResultController extends AbstractBean {
    @Autowired
    private AppraiseResultService appraiseResultService;


    /**
     * 评价综合结果分页查询
     *
     * @param req 请求参数
     * @return 通用返回
     */
    @GetMapping("/page")
    @Pageable(sortType = "desc", sortBy = AppraiseResult.Fields.updateTime)
    public JsonResult page(ResultPageReqDTO req) {
        return JsonResult.ok(appraiseResultService.page(req));
    }


    /**
     * 状态评估详情
     *
     * @param machineNo 机组编号
     * @return List<AppraiseResult>
     */
    @GetMapping("/getAppraiseByMachineNo")
    public JsonResult getAppraiseResultByMachineNo(@RequestParam(required = true) String machineNo) {
        return JsonResult.ok(appraiseResultService.getAppraiseResultByMachineNo(machineNo));
    }
}
